package logic.UIProxyBag.uieditescene
{
	/**
	 * 
	 */	
	import common.core.GEevnt;
	import common.core.UIService;
	import common.manager.GUI;
	import common.manager.ObserverEvt;
	
	import component.untils.ComponentItem;
	
	import logic.manager.UIProxy;
	import logic.ui.uieditscene.ScanUITreeMed;
	import logic.ui.uieditscene.UIContainMed;

	public class ScanUITreeProxy extends UIService
	{
		public function ScanUITreeProxy()
		{
			
		}
		
		public override function destory():void
		{
			
		}
		
		public override function start(value:* = null):void
		{	
			super.start();
			
			var ui : ScanUITreeMed = new ScanUITreeMed;
			
			GUI.add(ScanUITreeMed.NAME,ui,false);
			GUI.setAlgin(ScanUITreeMed.NAME,GUI.ALIGN_MIDDLE);
			
			GUI.open(ScanUITreeMed.NAME);
			GUI.autoAlgin();
			
			(GUI.find(ScanUITreeMed.NAME) as ScanUITreeMed).refreshTree(UIProxy.UIContain.uiRootFrameGroup);
			
			ObserverEvt.addRec(UIContainMed.ROOTFRAMEGROUPINFO,this,onRecUIRootGroupInfo);
		}
		
		public override function stop():void
		{
			super.stop();
			
			ObserverEvt.removeRec(UIContainMed.ROOTFRAMEGROUPINFO,this,onRecUIRootGroupInfo);
			
			GUI.remove(ScanUITreeMed.NAME);
		}
		
		public override function turn() : void
		{	
			if(curStatu == UIService.STATU_STOP)
			{
				start();
			}
			else if(curStatu == UIService.STATU_RUNING)
			{
				stop();
			}
		}
		
		private function onRecUIRootGroupInfo(evt : GEevnt) : void
		{
			var scanUITree : ScanUITreeMed = GUI.find(ScanUITreeMed.NAME) as ScanUITreeMed;
			
			scanUITree.refreshTree(evt.data as Vector.<ComponentItem>);
		}
	}
}